<!-- 公司sop配置 -->
<template>
  <dt-modal-edit
    ref="info"
    title="任务扣分分值设置"
    :label-width="100"
    okText="确定"
    :width="800"
    @ok="onOk">
    <div class="taskSingle">
      <div class="taskName">任务名称：{{ currentRow.sopName }}</div>
      <span class="tips">
        <Icon type="md-alert" class="tips_icon" />
        提示：您可为每个“任务责任人”所对应的“角色”或人员设置扣分分值，当产生扣分时，对应的“责任人”将被扣除相应分值
      </span>
      <div class="downBox">
        <div class="sourceTit">
          <span>任务责任人</span>
          <span>扣分值</span>
        </div>
        <div class="sourcedataCon">
          <ul>
            <li
              v-for="(item, index) in data"
              :key="index"
              style="margin-top: 10px">
              <div>
                {{ item.reviewerName }}
              </div>
              <div class="upDown">
                <Input
                  v-model="item.score"
                  type="number"
                  placeholder="请输入扣分值">
                  <span slot="append">分</span>
                </Input>
              </div>
            </li>
          </ul>
        </div>
      </div>
    </div>
  </dt-modal-edit>
</template>

<script>
  import sopApi from '@/biz/buildingManagement/sopConfig'
  export default {
    components: {},
    data() {
      return {
        currentRow: {},
        data: []
      }
    },

    methods: {
      scoreList() {
        let params = {
          configId: this.currentRow.id
        }
        return sopApi
          .scoreList(params)
          .then((res) => {
            this.data = res
          })
          .catch((err) => {})
      },

      scoreUpdate() {
        let params = {
          configId: this.currentRow.id,
          scoreList: this.data
        }
        return sopApi
          .scoreUpdate(params)
          .then((res) => {
            this.$Message.success('设置成功')
            this.$refs.info.hide()
            this.$parent.$refs.table.fetch()
          })
          .catch((err) => {})
      },
      show(data) {
        this.currentRow = data
        this.scoreList()
        this.$refs.info.show()
      },
      onOk() {
        this.scoreUpdate()
      }
    }
  }
</script>
<style lang="scss" scoped>
  .downBox {
    border: 1px solid #e8e8e8;
    padding: 20px;
    margin-top: 10px;
  }

  .tips {
    text-align: right;
    line-height: 32px;
    font-size: 14px;
    background: rgba(254, 252, 236, 1);

    .tips_icon {
      font-size: 20px;
      color: #0f42a7;
      vertical-align: sub;
    }
  }

  .sourceTit {
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    padding: 10px 0;
    border-bottom: 1px solid #e8e8e8;

    > span {
      width: 50%;
    }

    span:last-child {
      text-align: center;
    }
  }

  .sourcedataCon {
    max-height: 400px;
    height: 400px;
    overflow-y: auto;
    border-top: 0px;

    ul > li {
      margin: 0;
      line-height: normal;
      padding: 7px 0px;
      clear: both;
      color: #515a6e;
      font-size: 14px !important;
      white-space: nowrap;
      list-style: none;
      display: flex;
      flex-direction: row;
      position: relative;

      input {
        margin-top: 1px;
        cursor: pointer;
      }

      label {
        margin: 0 4px;
        cursor: pointer;
        min-width: 120px;
      }

      .upDown {
        position: absolute;
        right: 5px;
        cursor: pointer;

        em {
          color: #0f42a7;
          font-style: normal;
        }
      }
    }
  }
</style>
